﻿<%@ Page Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true" CodeBehind="DoccumentHouses.aspx.cs" Inherits="NEWS.Admin.DoccumentHouses" %>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>

<asp:Content ID="content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
   
    <script type="text/javascript">
    function confirmAction()
     {
        if(confirm('Bạn có chắc chắn muốn xóa???'))
        {
            // you clicked the OK button.
            // you can allow the form to post the data.
            return true;
        }
        else 
            // you clicked the Cancel button.
            // you can disallow the form submission.
            return false;
     }
     
     function confirmApprove()
     {
        if(confirm('Bạn có chắc chắn muốn kích hoạt văn bản này ?'))
        {
            // you clicked the OK button.
            // you can allow the form to post the data.
            return true;
        }
        else 
            // you clicked the Cancel button.
            // you can disallow the form submission.
            return false;
     }
     
     function SelectAll(CheckBox)
     {
        TotalChkBx = parseInt('<%= this.GridView1.Rows.Count %>');    
        var TargetBaseControl = document.getElementById('<%= this.GridView1.ClientID %>');
        var TargetChildControl = "chkSelect";   
        var Inputs = TargetBaseControl.getElementsByTagName("input");
        for(var iCount = 0; iCount < Inputs.length; ++iCount)
        {                
            if(Inputs[iCount].type == 'checkbox' && Inputs[iCount].id.indexOf(TargetChildControl,0) >= 0)
                Inputs[iCount].checked = CheckBox.checked;   
        }

    }
    
    function SelectDeSelectHeader(CheckBox)
    {        
        TotalChkBx = parseInt('<%= this.GridView1.Rows.Count %>');    
        var TargetBaseControl = document.getElementById('<%= this.GridView1.ClientID %>');
        var TargetChildControl = "chkSelect";   
        var TargetHeaderControl = "chkSelectAll";   
        var Inputs = TargetBaseControl.getElementsByTagName("input");
        var flag = false;
        var HeaderCheckBox;
        for(var iCount = 0; iCount < Inputs.length ; ++iCount)
        {    
            if(Inputs[iCount].type == 'checkbox' && Inputs[iCount].id.indexOf(TargetHeaderControl,0) >= 0)            
                HeaderCheckBox = Inputs[iCount];            
            if(Inputs[iCount] != CheckBox && Inputs[iCount].type == 'checkbox' && Inputs[iCount].id.indexOf(TargetChildControl,0) >= 0 && Inputs[iCount].id.indexOf(TargetHeaderControl,0) == -1)
            {            
                if(CheckBox.checked)
                {                    
                    if(!Inputs[iCount].checked)                    
                    {                    
                        flag = false;
                        HeaderCheckBox.checked = false;                       
                        return;
                    }
                    else
                        flag = true;                    
                }
                else if(!CheckBox.checked)                
                    HeaderCheckBox.checked = false;                                                       
            }            
        }                      
        if(flag)        
            HeaderCheckBox.checked = CheckBox.checked        
    }
</script>
<asp:ScriptManager ID="ScriptManager1" runat="server">
                    </asp:ScriptManager>
           <asp:Panel ID="PanelDasboard" runat="server"  Visible="true">                        
            <div class="dashboard">
                <asp:Panel ID="pn_result" Visible="false" runat="server">                
                    <div style="border:solid 1px coral; width:100%; text-align:center; height:30px; background:#FFFFCC; margin-bottom:10px;">                    
                        <asp:Label style="line-height:25px;" ID="lblthongbao" runat="server" Text="Thông Báo" ForeColor="Black" 
                            Font-Bold="True"></asp:Label>
                    </div>
                </asp:Panel> 
                <h2 class="ico_mug">
                    <asp:Label ID="lblxem_duyet" runat="server" Text="Danh sách Văn bản nhà đất"></asp:Label>
                </h2>                  
                <asp:Panel ID="pn_add_edit" runat="server">                           
                <div style="width:100%;">
                    <p style="margin-right:10px;float:left;">
                        <asp:LinkButton ID="btnUpload" runat="server" Font-Bold="True" ForeColor="Blue" 
                            onclick="btnUpload_Click" CausesValidation="False">Upload Văn Bản Mới</asp:LinkButton></p>
                    <p><asp:LinkButton ID="btnxoa" runat="server" 
                            OnClientClick="javascript:return confirmAction();" Font-Bold="True" 
                            ForeColor="Blue" onclick="btnxoa_Click" CausesValidation="False">Xoá văn bản 
                        được chọn</asp:LinkButton></p>
                </div>
                </asp:Panel>                 
                <asp:Panel ID="pn_approve" Visible="false" runat="server">
                <div style="width:100%;margin-bottom:10px;">
                    <asp:Button ID="btnapprove" runat="server" 
                        OnClientClick="javascript:return confirmApprove();" Text="Duyệt Tin Được Chọn" 
                        onclick="btnapprove_Click" />
                    <asp:Button ID="btnapproveall" runat="server" 
                        OnClientClick="javascript:return confirmApprove();" Text="Duyệt Tất Cả" 
                        onclick="btnapproveall_Click" />
                </div>
                </asp:Panel>
                <div>
                    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                        CellPadding="4" DataKeyNames="TextHouseID" Width="100%" 
                        onselectedindexchanged="GridView1_SelectedIndexChanged" AllowPaging="True" 
                        ForeColor="#333333" GridLines="None" 
                        onrowdatabound="GridView1_RowDataBound" 
                        onrowcommand="GridView1_RowCommand">
                        <FooterStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True" />
                        <RowStyle BackColor="#EFF3FB" />
                        <Columns>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:LinkButton ID="btnxem" runat="server" CommandName="Xem">Xem</asp:LinkButton>
                                </ItemTemplate>
                                <ItemStyle Width="30px" />
                            </asp:TemplateField>
                            <asp:CommandField 
                                ShowSelectButton="True" SelectText="Sửa" >
                                <ItemStyle Width="30px" HorizontalAlign="Center" />
                            </asp:CommandField>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:CheckBox ID="chkSelect" runat="server" />
                                </ItemTemplate>
                                <HeaderTemplate>
                                 <asp:CheckBox ID="chkSelectAll" runat="server" onclick="SelectAll(this);" />                                
                                </HeaderTemplate>
                                <ItemStyle Width="15px" />
                            </asp:TemplateField>
                            <asp:BoundField DataField="TextHouseID" HeaderText="Mã Văn Bản" ReadOnly="True" 
                                SortExpression="TextHouseID" InsertVisible="False" >
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                            <asp:BoundField DataField="Title" HeaderText="Tên Văn Bản" 
                                SortExpression="Title" >
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                            <asp:BoundField DataField="CreatedDate" HeaderText="Ngày Upload" SortExpression="CreatedDate">
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                            <asp:TemplateField HeaderText="Kích Hoạt">
                                <ItemTemplate>
                                    <asp:CheckBox ID="cboxkichhoat" runat="server" Enabled="false"
                                        Checked='<%# Eval("IsActive") %>' />
                                </ItemTemplate>
                                <HeaderStyle Width="80px" />
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Chọn Tin" Visible="False">
                                <ItemTemplate>
                                    <asp:CheckBox ID="cbapprove" runat="server" />
                                </ItemTemplate>
                                <HeaderStyle Width="70px" />
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                        </Columns>
                        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                        <EditRowStyle BackColor="#2461BF" />
                        <AlternatingRowStyle BackColor="White" />
                    </asp:GridView>
                    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
                        SelectMethod="GetTextHouseBOList" 
                        TypeName="HousingInfo.Library.TextHouseBOList">
                    </asp:ObjectDataSource>
                    <asp:Label ID="messagedelete" runat="server" Font-Bold="True" Font-Size="Small" 
                        ForeColor="Red"></asp:Label>
                    <br />
                </div>
            </div>            
       </asp:Panel>       
    <asp:Panel ID="PanelActions" runat="server"  Visible="false">
    <div class="dashboard">
        <h2 class="ico_mug">
            <asp:Label ID="lbHeaderActions" runat="server" Text="Chỉnh sửa"></asp:Label>
        </h2>
        <div>
            <table style="width: 100%">
                <tr>
                    <td style="width: 132px">
                        &nbsp;</td>
                    <td style="width: 19px">
                        &nbsp;</td>
                    <td>
                        <asp:Label ID="message" runat="server" Font-Bold="True" Font-Size="Small" 
                            ForeColor="Red"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td style="width: 132px; text-align: right;">
                        <asp:Label ID="lbldoccumentid" runat="server" Text="Mã văn bản :"></asp:Label>
                    </td>
                    <td style="width: 19px">
                        &nbsp;</td>
                    <td>
                        <asp:TextBox ID="txtdoccumentid" runat="server" ReadOnly="True" Width="172px" 
                            Enabled="False"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td style="width: 132px; text-align: right;">
                        <asp:Label ID="Label2" runat="server" Text="Tên văn bản :"></asp:Label>
                    </td>
                    <td style="width: 19px">
                        &nbsp;</td>
                    <td>
                        <asp:TextBox ID="txtdoccumentname" runat="server" Width="172px" MaxLength="50"></asp:TextBox>                                                
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                            ControlToValidate="txtdoccumentname" ErrorMessage="?"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" 
                            ControlToValidate="txtdoccumentname" ErrorMessage="Độ dài tối thiểu &gt; 1 và tối đa là 50" 
                            ValidationExpression="^([\S\s]{2,50})$"></asp:RegularExpressionValidator>
                    </td>
                </tr>
                
                <tr>
                    <td style="width: 132px; text-align: right;">
                        <asp:Label ID="lblink" runat="server" Text="Tên File Văn Bản :"></asp:Label>
                    </td>
                    <td style="width: 19px">
                        &nbsp;</td>
                    <td>
                        <asp:TextBox ID="txtlink" Width="172px" Enabled="false" runat="server"></asp:TextBox>
                        <asp:LinkButton ID="btndownload" runat="server" 
                            ForeColor="#666699" Font-Bold="True" onclick="btndownload_Click">Download</asp:LinkButton>
                        <asp:LinkButton ID="btnthaydoivanban" Visible="false" runat="server" 
                            ForeColor="#666699" Font-Bold="True" onclick="btnthaydoivanban_Click" 
                            CausesValidation="False">Thay Đổi Văn Bản</asp:LinkButton>
                    </td>
                </tr>
                <asp:Panel ID="pn_upload" runat="server" Visible="false">
                    <tr>
                        <td style="width: 132px; text-align: right;">
                            <asp:Label ID="lbchonfile" runat="server" Text="Chọn File Văn Bản Thay Đổi :"></asp:Label>
                        </td>
                        <td style="width: 19px">
                            &nbsp;</td>
                        <td>
                            <asp:FileUpload ID="FileUpload_Doccument" Width="220px" runat="server" />
                            <asp:LinkButton ID="testupload" OnClick="testupload_Click" runat="server" ForeColor="#666699" Font-Bold="True" CausesValidation="False">Upload</asp:LinkButton>                            
                            <asp:LinkButton ID="btnhuychonfile" OnClick="btnhuychonfile_Click" runat="server" ForeColor="#666699" CausesValidation="false" Font-Bold="True">Huỷ</asp:LinkButton>
                        </td>
                    </tr>
                </asp:Panel>
                <tr>
                    <td style="width: 132px; text-align: right;">
                        <asp:Label ID="lbluocxem" runat="server" Text="Lượt Xem :"></asp:Label>
                    </td>
                    <td style="width: 19px">
                        &nbsp;</td>
                    <td>
                        <asp:TextBox ID="txtluotxem" runat="server" ReadOnly="True" Width="172px" 
                            Enabled="False"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td style="width: 132px; text-align: right;">
                        <asp:Label ID="lbluotdown" runat="server" Text="Lượt Download :"></asp:Label>
                    </td>
                    <td style="width: 19px">
                        &nbsp;</td>
                    <td>
                        <asp:TextBox ID="txtluotdown" runat="server" ReadOnly="True" Width="172px" 
                            Enabled="False"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td style="width: 132px; text-align: right;">
                        <asp:Label ID="lbuploaddate" runat="server" Text="Ngày Upload :"></asp:Label>
                    </td>
                    <td style="width: 19px">
                        &nbsp;</td>
                    <td>
                        <asp:TextBox ID="txtuploaddate" runat="server" ReadOnly="True" Width="172px" 
                            Enabled="False"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td style="width: 132px; text-align: right;">
                        <asp:Label ID="Label1" runat="server" Text="Kích Hoạt :"></asp:Label>
                    </td>
                    <td style="width: 19px">
                        &nbsp;</td>
                    <td>
                        <asp:CheckBox ID="cbisactive" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td style="width: 132px">
                        &nbsp;</td>
                    <td style="width: 19px">
                        &nbsp;</td>
                    <td>
                        &nbsp;</td>
                </tr>
                <tr>
                    <td style="width: 132px">
                        &nbsp;</td>
                    <td style="width: 19px">
                        &nbsp;</td>
                    <td>
                        <asp:Button ID="btnUpdate" runat="server" Text="Cập nhật" 
                            onclick="btnUpdate_Click" />
                        <asp:Button ID="btnDelete" runat="server" onclick="btnDelete_Click"  OnClientClick="javascript:return confirmAction();"
                            Text="Xóa" />
                        <asp:Button ID="btnAdd" runat="server" onclick="btnAdd_Click" Text="Thêm" />
                        <asp:Button ID="btndong" runat="server" Text="Đóng" onclick="btndong_Click" 
                            CausesValidation="False" />
                    </td>
                </tr>
            </table>
        </div>
        <iframe src="http://docs.google.com/gview?url=VanBan/soft-skill1.pdf&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>
    </div>
     </asp:Panel>
</asp:Content>
